/***************************************************
> Copyright (C) 2024 ==KINGYI== All rights reserved.
> File Name: nwk8.6.2.c
> Author:
> Mail: 
> Created Time: Tue 06 Aug 2024 02:55:39 AM PDT
***************************************************/

//进程中安装SIGINT，SIGUSRI，SIGALRM三种信号并测试

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

void fun(int sig)
{ 
	printf("hello world\n");
}



int main(int argc,const char* argv[])
{
	signal(SIGINT, fun);
	printf("%d\n",getpid());
	while(1)
	{
		printf("ni hao\n");
		sleep(1);
		raise(SIGINT);
	}

	return 0;
}

int main()
{

	signal(SIGALRM,fun);
	alarm(5);
	while(1)
	{
		printf("ni hao\n");
		sleep(1);
	}
	return 0;
}

int main()
{
	signal(SIGURSI,fun);
	alarm(5);
	while(1)
	{
		printf("ni hao\n");
		sleep(1);
	}
}
